package com.lihepeng.leecode.leetcodeDataStruct.easy;

import com.lihepeng.leecode.linkedList.ListNode;

/**
 * 翻转链表
 *
 */
public class Solution206 {
    /**
     * 使用快慢指针方案进行翻转
     * @param head
     * @return
     */
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode cur = head;
        while(cur!=null){
           ListNode nextNode =  cur.next;
           cur.next = prev;
           prev = cur;
           cur = nextNode;

        }
        return prev;
    }
}
